package com.example.pengsiyuan.ppbluetoothle.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.pengsiyuan.ppbluetoothle.R;
import com.peng.ppscalelibrary.BleManager.Interface.BleBMDJExitInterface;
import com.peng.ppscalelibrary.BleManager.Interface.BleBMDJParttenInterface;
import com.peng.ppscalelibrary.BleManager.Manager.BleManager;

public class BMDJIntroduceActivity extends AppCompatActivity {

    private boolean isAutoPush;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.isAutoPush = false;
        setContentView(R.layout.activity_bmdjintroduce);

        BleManager.shareInstance(getApplication()).intoBMDJPattern(new BleBMDJParttenInterface() {
            @Override
            public void startTiming() {
                isAutoPush = true;
                Intent intent = new Intent(BMDJIntroduceActivity.this, BMDJTimeActivity.class);
                startActivity(intent);
            }

        });
        BleManager.shareInstance(getApplication()).exitBMDJPattern(new BleBMDJExitInterface() {
            @Override
            public void exitSuccess() {
                BleManager.shareInstance(getApplication()).dissconnectBMScale();
            }

            @Override
            public void exitFailed() {

            }
        });
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (!isAutoPush){
            BleManager.shareInstance(getApplication()).dissconnectBMScale();
        }
    }
}
